#include<iostream>
using namespace std;

struct  control_block
{
    int reference;
    control_block():reference(1){}
};


template<class T>
class simple_smartPointer{
private:
    T* pointer;
    control_block* block;
    void release(){
        if(block){
            block->reference--;
            if(block->reference==0){
                delete pointer;
                delete block;
            }
        }

    }
public:
    simple_smartPointer():pointer(nullptr),block(nullptr){}
    explicit simple_smartPointer(T* p):pointer(p){
        if(p){
            block=new control_block();
        }
        else{
            block=nullptr;
        }
    }
    ~simple_smartPointer(){
        if(pointer){  //当空指针构造或者默认构造时，我们便可以直接析构
            release();
            pointer=nullptr;
            block=nullptr;
        }
    }
    simple_smartPointer(const simple_smartPointer& s):pointer(s.pointer),block(s.block){
        if(block){
            block->reference++;
        }        
    }
    simple_smartPointer& operator=(const simple_smartPointer& s){
        if(this!=&s){
            release();
            this->block=s.block;
            this->pointer=s.pointer;
            if(block){
                block->reference++;
            }   
        }
        return *this;
    }
    //simple_smartPointer s1(move(s2));
    simple_smartPointer(simple_smartPointer&& s):pointer(s.pointer),block(s.block){
        s.block=nullptr;
        s.pointer=nullptr;
    }
};

int main(){


    return 0;
}